﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ServiceStack.Redis;
using ServiceStack.Common.Utils;
using System.Reflection;
using System.Diagnostics;
using ServiceStack.Text;
using ServiceStack.CacheAccess;
using RedisDemo.ProductEntities;

namespace RedisDemo
{
    class Program
    {
        private static int counter = 0;
        static void Main(string[] args)
        {
            Console.WriteLine("press any key to start");
            Console.ReadKey(true);
            CancellationToken ct =new CancellationToken();
            bool timeout = Task.Factory.StartNew(() => { Thread.Sleep(300);
                Console.WriteLine("wake up");
            },ct).Wait(200);
            
            //Console.WriteLine(sr.ReadToEnd());
            //ExpireTest();
            //HashSetGetTest();
            //EntryListTest();
            //HashTest();
            //HashGetTest();
            //EntryTest();
            //HashSetTest();
            //EntryGetTest();
            //ProductTest_Flatten();
            ProductTest();
            Console.WriteLine("press any key to close");
            Console.ReadKey(true);
        }
           
        static void ProductTest()
        {
            Dictionary<string, string> dicProduct = new Dictionary<string, string>();

            //List<Dictionary<string, string>> segHotelList = new List<Dictionary<string, string>>();
            //IEnumerable<KeyValuePair<string, string>> dictSegHotel = new Dictionary<string, string>();
            //for (int i = 0; i < 500; i++)
            //{
            //    if (i > 0 && i % 50 == 0)
            //    {
            //        //segHotelList.Add(dictSegHotel);
            //        segHotelList.Add(dictSegHotel.ToDictionary(kv => kv.Key, kv => kv.Value));
            //        //dictSegHotel = new Dictionary<string, string>();
            //    }
            //    //string hotelString = new SegmentHotel().Dummy().ToJson();
            //    //dictSegHotel.Add("SegmentHotel:" + i, hotelString);
            //    dictSegHotel = dictSegHotel.Union(new SegmentHotel().Dummy().ToDictionary("SegmentHotel:" + i));
            //}
            ////segHotelList.Add(dictSegHotel);
            //segHotelList.Add(dictSegHotel.ToDictionary(kv => kv.Key, kv => kv.Value));


            //List<string> monsterList = new List<string>();
            //monsterList.Add(new ProductDesc().Dummy().GetIntroduction());
            //List<Dictionary<string, string>> scenicSpotList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> scenicSpotDict = new Dictionary<string, string>();
            List<string> scenicSpotList = new List<string>();
            for (int i = 0; i < 50; i++)
            {
                string scenicSpotString = new ScenicSpot().Dummy().ToJson();
                //scenicSpotDict.Add(i.ToString(), scenicSpotString);
                scenicSpotList.Add(scenicSpotString);
                //dicProduct.Add("SS:"+i,scenicSpotString);
            }
            dicProduct.Add("SS:", scenicSpotList.ToJson());
            //scenicSpotList.Add(scenicSpotDict);

            //List<Dictionary<string, string>> flightsList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> flightsDict = new Dictionary<string, string>();
            //List<string> flightsList = new List<string>();
            List<Flights> flightsList = new List<Flights>();

            for (int i = 0; i < 100; i++)
            {
                //string item = new Flights().Dummy().ToJson();
                //flightsDict.Add(i.ToString(), item);
                flightsList.Add(new Flights().Dummy());
                //dicProduct.Add("Flights:"+i, item);
            }
            dicProduct.Add("Flights:", flightsList.ToJson());

            //flightsList.Add(flightsDict);

            //List<Dictionary<string, string>> xResourceList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> xResourceDict = new Dictionary<string, string>();
            //List<string> xResourceList = new List<string>();
            List<XResource> xResourceList = new List<XResource>();
            for (int i = 0; i < 200; i++)
            {
                //string item = new XResource().Dummy().ToJson();
                //xResourceList.Add(item);
                xResourceList.Add(new XResource().Dummy());

                //dicProduct.Add("XRs:" + i, item);
                //xResourceDict.Add(i.ToString(), item);
            }
            dicProduct.Add("XRs:", xResourceList.ToJson());
            //xResourceList.Add(xResourceDict);


            //List<Dictionary<string, string>> segmentHotelList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> segmentHotelDict = new Dictionary<string, string>();
            List<string> segmentHotelList = new List<string>();
            for (int i = 0; i < 500; i++)
            {
                string item = new SegmentHotel().Dummy().ToJson();
                segmentHotelList.Add(item);
                //segmentHotelDict.Add(i.ToString(), item);
            }
            //segmentHotelList.Add(segmentHotelDict);

            


            //List<Dictionary<string, string>> timeEffectDetailList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> timeEffectDetailDict = new Dictionary<string, string>();
            //List<string> timeEffectInfoDetailList = new List<string>();
            //for (int i = 0; i < 70; i++)
            //{
            //    string item = new TimeEffectInfoDetail().Dummy().ToJson();
            //    timeEffectInfoDetailList.Add(item);
            //    //timeEffectDetailDict.Add(i.ToString(), item);
            //}
            //timeEffectDetailList.Add(timeEffectDetailDict);
            //Dictionary<string, string> timeEffectDetailDescDict = new Dictionary<string, string>();
            //for (int i = 0; i < 70; i++)
            //{
            //    string item = new TimeEffectInfoDetail().Dummy().GetDescDetail();//.ToJson();
            //    timeEffectDetailDescDict.Add(i.ToString(), item);
            //}

            //List<Dictionary<string, string>> segmentDetailList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> segmentDetailDict = new Dictionary<string, string>();

            //segmentDetailList.Add(segmentDetailDict);
            //Dictionary<string, string> segmentDetailDescDict = new Dictionary<string, string>();
            //for (int i = 0; i < 50; i++)
            //{
            //    string item = new SegmentDetail().Dummy().GetDescription();//.ToJson();
            //    segmentDetailDescDict.Add(i.ToString(), item);
            //}


            //List<Dictionary<string, string>> segScenicList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> segScenicDict = new Dictionary<string, string>();
            //for (int i = 0; i < 100; i++)
            //{
            //    string item = new SegScenic().Dummy().ToJson();
            //    segScenicDict.Add(i.ToString(), item);
            //}
            //segScenicList.Add(segmentDetailDict);

            //dicProduct.Add("HT:", "Prod:12345:Hotel");
            //dicProduct.Add("SS:", "Prod:12345:ScenicSpot");
            //dicProduct.Add("Flt:", "Prod:12345:Flights");
            //dicProduct.Add("XR:", "Prod:12345:XResource");
            //dicProduct.Add("Sgh:", "Prod:12345:SegmentHotel");
            //dicProduct.Add("Pic:", "Prod:12345:Pictures");
            //dicProduct.Add("TEF:", "Prod:12345:TimeEffectInfo");
            //dicProduct.Add("TEFD:", "Prod:12345:TimeEffectInfoDetail");
            //dicProduct.Add("TEFDC:", "Prod:12345:TimeEffectInfoDetailCity");
            //dicProduct.Add("SegD:", "Prod:12345:SegmentDetail");
            //dicProduct.Add("SegS:", "Prod:12345:SegScenic");

            //dicProduct = dicProduct
            //    //.Union(new ControlFlight().Dummy().ToDictionary("ControlFlight:"))
            //    //.Union(new CustomizedSalesLabel().Dummy().ToDictionary("CustomizedSalesLabel:"))
            //    //.Union(new DepartCity().Dummy().ToDictionary("DepartCity:"))
            //    //.Union(new FlightRule().Dummy().ToDictionary("FlightRule:"))
            //    //.Union(new Flights().Dummy().ToDictionary("Flights:"))
            //    //.Union(new Hotel().Dummy().ToDictionary("Hotel:"))
            //    //.Union(new HotelRule().Dummy().ToDictionary("HotelRule:"))
            //    //.Union(new MultiMediaVedio().Dummy().ToDictionary("MultiMediaVedio:"))
            //    //.Union(new OptionRule().Dummy().ToDictionary("OptionRule:"))
            //    //.Union(new Pictures().Dummy().ToDictionary("Pictures:"))
            //    .Union(new ProductDesc().Dummy().ToDictionary("ProductDesc:"))
            //    .Union(new ProductInfo().Dummy().ToDictionary("ProductInfo:"))
            //    //.Union(new SalesChannel().Dummy().ToDictionary("SalesChannel:"))
            //    //.Union(new SalesLabel().Dummy().ToDictionary("SalesLabel:"))
            //    //.Union(new ScenicSpot().Dummy().ToDictionary("ScenicSpot:"))
            //    //.Union(new Segment().Dummy().ToDictionary("Segment:"))
            //    //.Union(new SegmentDesc().Dummy().ToDictionary("SegmentDesc:"))
            //    //.Union(new SegmentDetail().Dummy().ToDictionary("SegmentDetail:"))
            //    //.Union(new SegmentMeal().Dummy().ToDictionary("SegmentMeal:"))
            //    //.Union(new SegScenic().Dummy().ToDictionary("SegScenic:"))
            //    //.Union(new SellingCity().Dummy().ToDictionary("SellingCity:"))
            //    //.Union(new SysFlightRule().Dummy().ToDictionary("SysFlightRule:"))
            //    //.Union(new SysFlightRuleDetail().Dummy().ToDictionary("SysFlightRuleDetail:"))
            //    //.Union(new TimeEffectInfo().Dummy().ToDictionary("TimeEffectInfo:"))
            //    //.Union(new TimeEffectInfoDetail().Dummy().ToDictionary("TimeEffectInfoDetail:"))
            //    //.Union(new TimeEffectInfoDetailCity().Dummy().ToDictionary("TimeEffectInfoDetailCity:"))
            //    //.Union(new XResource().Dummy().ToDictionary("XResource:"))
            //    .ToDictionary(kv => kv.Key, kv => kv.Value);

            dicProduct.Add("PI:", new ProductInfo().Dummy().ToJson());
            dicProduct.Add("PD:", new ProductDesc().Dummy().ToJson());

            //IEnumerable<KeyValuePair<string, string>> dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<ControlFlight> controlFlightList = new List<ControlFlight>();
            for (int i = 0; i < 6; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new ControlFlight().Dummy().ToDictionary("ControlFlight:" + i));
                //ControlFlight item = new ControlFlight().Dummy();
                //dicProduct.Add("ControlFlight:" + i, item.ToJson());
                controlFlightList.Add(new ControlFlight().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("CF:", controlFlightList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<CustomizedSalesLabel> customizedSalesLabelList = new List<CustomizedSalesLabel>();
            for (int i = 0; i < 2; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new CustomizedSalesLabel().Dummy().ToDictionary("CustomizedSalesLabel:" + i));
                //CustomizedSalesLabel item = new CustomizedSalesLabel().Dummy();
                //dicProduct.Add("CustomizedSalesLabel:" + i, item.ToJson());
                customizedSalesLabelList.Add(new CustomizedSalesLabel().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("CSL:", customizedSalesLabelList.ToJson());

            //monster in memory
            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<DepartCity> departCityList = new List<DepartCity>();
            for (int i = 0; i < 65; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new DepartCity().Dummy().ToDictionary("DepartCity:" + i));
                //DepartCity item = new DepartCity().Dummy();
                //dicProduct.Add("DepartCity:" + i, item.ToJson());
                departCityList.Add(new DepartCity().Dummy());
                //dicProduct.Add("DC:" + i, new DepartCity().Dummy().ToJson());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("DC:", departCityList.ToJson());

            //monster in memory             
            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<FlightRule> flightRuleList = new List<FlightRule>();
            for (int i = 0; i < 5; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new FlightRule().Dummy().ToDictionary("FlightRule:" + i));
                //FlightRule rule = new FlightRule().Dummy();
                //dicProduct.Add("FR:" + i, rule.ToJson());
                flightRuleList.Add(new FlightRule().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("FR:", flightRuleList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<HotelRule> hotelRuleList = new List<HotelRule>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new HotelRule().Dummy().ToDictionary("HotelRule:" + i));
                //HotelRule item = new HotelRule().Dummy();
                //dicProduct.Add("HotelRule:" + i, item.ToJson());
                hotelRuleList.Add(new HotelRule().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("HR:", hotelRuleList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<MultiMediaVedio> multiMediaVedioList = new List<MultiMediaVedio>();
            for (int i = 0; i < 4; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new MultiMediaVedio().Dummy().ToDictionary("MultiMediaVedio:" + i));
                //MultiMediaVedio item = new MultiMediaVedio().Dummy();
                //dicProduct.Add("MultiMediaVedio:" + i, item.ToJson());
                multiMediaVedioList.Add(new MultiMediaVedio().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("MMV:", multiMediaVedioList.ToJson());


            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<OptionRule> optionRuleList = new List<OptionRule>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new OptionRule().Dummy().ToDictionary("OptionRule:" + i));
                //OptionRule item = new OptionRule().Dummy();
                //dicProduct.Add("OptionRule:" + i, item.ToJson());
                optionRuleList.Add(new OptionRule().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("OR:", optionRuleList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SalesChannel> salesChannelList = new List<SalesChannel>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SalesChannel().Dummy().ToDictionary("SalesChannel:" + i));
                //SalesChannel item = new SalesChannel().Dummy();
                //dicProduct.Add("SalesChannel:" + i, item.ToJson());
                salesChannelList.Add(new SalesChannel().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("SCH:", salesChannelList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<Segment> segmentList = new List<Segment>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new Segment().Dummy().ToDictionary("Segment:" + i));
                //Segment item = new Segment().Dummy();
                //dicProduct.Add("Segment:" + i, item.ToJson());
                segmentList.Add(new Segment().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("Sg:", segmentList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SegmentDesc> segmentDescList = new List<SegmentDesc>();
            for (int i = 0; i < 15; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SegmentDesc().Dummy().ToDictionary("SegmentDesc:" + i));
                //SegmentDesc item = new SegmentDesc().Dummy();
                //dicProduct.Add("SegmentDesc:" + i, item.ToJson());
                //var item = new SegmentDesc().Dummy();
                //dicProduct.Add("Sgd:" + i, item.ToJson());
                segmentDescList.Add(new SegmentDesc().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("Sgd:", segmentDescList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SegmentMeal> segmentMealList = new List<SegmentMeal>();
            for (int i = 0; i < 50; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SegmentMeal().Dummy().ToDictionary("SegmentMeal:" + i));
                //SegmentMeal item = new SegmentMeal().Dummy();
                //dicProduct.Add("SegmentMeal:" + i, item.ToJson());
                segmentMealList.Add(new SegmentMeal().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("SGM:", segmentMealList.ToJson());

            List<SegmentDetail> segmentDetailList = new List<SegmentDetail>();
            for (int i = 0; i < 50; i++)
            {
                //var item = new SegmentDetail().Dummy();
                //dicProduct.Add("SGDL:" + i, item.ToJson());
                segmentDetailList.Add(new SegmentDetail().Dummy());
            }
            dicProduct.Add("SGDL:", segmentDetailList.ToJson());
            List<string> segmentDetailDescList = new List<string>();
            for (int i = 0; i < 50; i++)
            {
                string item = new SegmentDetail().Dummy().GetDescription();
                segmentDetailDescList.Add(item);
            }

            List<Calendar> calendarList = new List<Calendar>();
            for (int i = 0; i < 10; i++)
            {

                calendarList.Add(new Calendar().Dummy());
            }
            dicProduct.Add("Calendar:", segmentMealList.ToJson());

            List<string> segmentMealDescList = new List<string>();

            for (int i = 0; i < 50; i++)
            {
                string item = new SegmentMeal().Dummy().GetDescription();
                segmentMealDescList.Add(item);
            }
            List<TimeEffectInfoDetail> timeEffectInfoDetailList = new List<TimeEffectInfoDetail>();

            for (int i = 0; i < 40; i++)
            {
                //var item = new TimeEffectInfoDetail().Dummy();
                //dicProduct.Add("TEID:" + i, item.ToJson());
                timeEffectInfoDetailList.Add(new TimeEffectInfoDetail().Dummy());
                //timeEffectDetailDict.Add(i.ToString(), item);
            }
            dicProduct.Add("TEID:", timeEffectInfoDetailList.ToJson());

            List<string> timeEffectInfoDetailDescList = new List<string>();
            for (int i = 0; i < 40; i++)
            {
                string item = new TimeEffectInfoDetail().Dummy().GetDescDetail();
                timeEffectInfoDetailDescList.Add(item);
            }

    
            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SellingCity> sellingCityList = new List<SellingCity>();
            for (int i = 0; i < 65; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SellingCity().Dummy().ToDictionary("SellingCity:" + i));
                //SellingCity item = new SellingCity().Dummy();
                //dicProduct.Add("SellingCity:" + i, item.ToJson());
                //var item = new SellingCity().Dummy();
                //dicProduct.Add("SC:" + i, item.ToJson());
                sellingCityList.Add(new SellingCity().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("SC:", sellingCityList.ToJson());
            
            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SalesLabel> salesLabelList = new List<SalesLabel>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SalesLabel().Dummy().ToDictionary("SalesLabel:" + i));
                //SalesLabel item = new SalesLabel().Dummy();
                //dicProduct.Add("SalesLabel:" + i, item.ToJson());
                salesLabelList.Add(new SalesLabel().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("SL:", salesLabelList.ToJson());

            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SysFlightRule> sysFlightRuleList = new List<SysFlightRule>();
            for (int i = 0; i < 5; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SysFlightRule().Dummy().ToDictionary("SysFlightRule:" + i));
                //SysFlightRule item = new SysFlightRule().Dummy();
                //dicProduct.Add("SysFlightRule:" + i, item.ToJson());
                sysFlightRuleList.Add(new SysFlightRule().Dummy());
            }
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            dicProduct.Add("SFR:", sysFlightRuleList.ToJson());
            List<string> hotelList = new List<string>();
            for (int i = 0; i < 10; i++)
            {

                string item = new Hotel().Dummy().ToJson();
                //flightsDict.Add(i.ToString(), item);
                hotelList.Add(item);
            }
            dicProduct.Add("HOTEL:", hotelList.ToJson());
            //List<Dictionary<string, string>> pictureList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> pictureDict = new Dictionary<string, string>();
            List<Pictures> pictureList = new List<Pictures>();
            for (int i = 0; i < 20; i++)
            {
                //var item = new Pictures().Dummy();
                //dicProduct.Add("PIC:" + i, item.ToJson());
                pictureList.Add(new Pictures().Dummy());
                //pictureDict.Add(i.ToString(), item);
            }
            dicProduct.Add("PIC:", pictureList.ToJson());
            //pictureList.Add(pictureDict);

            //List<Dictionary<string, string>> timeEffectList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> timeEffectDict = new Dictionary<string, string>();
            List<TimeEffectInfo> timeEffectList = new List<TimeEffectInfo>();
            for (int i = 0; i < 60; i++)
            {

                //var item = new TimeEffectInfo().Dummy();
                //dicProduct.Add("TEFF:" + i, item.ToJson());
                timeEffectList.Add(new TimeEffectInfo().Dummy());
                //timeEffectDict.Add(i.ToString(), item);                
            }
            dicProduct.Add("TEFF:", timeEffectList.ToJson());
            //timeEffectList.Add(timeEffectDict);

            //List<Dictionary<string, string>> timeEffectCityList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> timeEffectCityDict = new Dictionary<string, string>();
            List<TimeEffectInfoDetailCity> timeEffectCityList = new List<TimeEffectInfoDetailCity>();
            for (int i = 0; i < 50; i++)
            {
                var item = new TimeEffectInfoDetailCity().Dummy();
                timeEffectCityList.Add(item);
                //dicProduct.Add("TEFFC:" + i, item.ToJson());
                //timeEffectCityDict.Add(i.ToString(), item);
            }
            dicProduct.Add("TEFFC:", timeEffectCityList.ToJson());
            //timeEffectCityList.Add(timeEffectCityDict);



            //monster in memory
            //dictEnumerator = new Dictionary<string, string>().AsEnumerable();
            List<SysFlightRuleDetail> sysFlightRuleDetailList = new List<SysFlightRuleDetail>();
            for (int i = 0; i < 10; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SysFlightRuleDetail().Dummy().ToDictionary("SysFlightRuleDetail:" + i));
                SysFlightRuleDetail item = new SysFlightRuleDetail().Dummy();
                //dicProduct.Add("SFRD:" + i, item.ToJson());
                sysFlightRuleDetailList.Add(new SysFlightRuleDetail().Dummy());
            }
            dicProduct.Add("SFRD:", sysFlightRuleDetailList.ToJson());
            //productEnumerator = productEnumerator.Union(dictEnumerator);
            //dicProduct.Add("SysFlightRuleDetail:", sysFlightRuleDetailList.ToJson());
            List<SegScenic> segScenicList = new List<SegScenic>();
            for (int i = 0; i < 20; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SysFlightRuleDetail().Dummy().ToDictionary("SysFlightRuleDetail:" + i));
                //SegScenic item = new SegScenic().Dummy();
                //dicProduct.Add("segS:" + i, item.ToJson());
                segScenicList.Add(new SegScenic().Dummy());
            }
            dicProduct.Add("segS:", segScenicList.ToJson());
            
            Stopwatch sw = new Stopwatch();
            sw.Start();
            PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            Dictionary<string, string> productIntroDic = new Dictionary<string, string>();
            string productIntro = new ProductDesc().Dummy().GetIntroduction();
            int k = 0;
            for (k = 0; k < 10000; k++)
            {
                if (k % 4 != 0)
                {
                    dicProduct["ProductDesc:Introduction"] = @"<span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" <span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" <span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" ";
                }
                //RedisClient client = new RedisClient("127.0.0.1", 6379);
                client.SetRangeInHash("product_" + k, dicProduct);
                client.AddRangeToList("product_" + k + ":SegH", segmentHotelList);
                //client.AddRangeToList("product_" + k + ":Pic", pictureList);
                //client.AddRangeToList("product_" + k + ":TE", timeEffectList);
                //client.AddRangeToList("product_" + k + ":TEC", timeEffectCityList);
                //client.AddRangeToList("product_" + k + ":TED", timeEffectInfoDetailList);
                //client.AddRangeToList("product_" + k + ":SEGD", segmentDetailList);

                client.AddRangeToList("product_" + k + ":SEGDD", segmentDetailDescList);
                client.AddRangeToList("product_" + k + ":SEGMD", segmentMealDescList);
                client.AddRangeToList("product_" + k + ":TEDD", timeEffectInfoDetailDescList);

                
                //client.AddRangeToList("product_" + k + ":monsters", monsterList);
                
                //client.SetRangeInHash("product_" + k + ":TED:Desc", timeEffectDetailDescDict);
                //client.SetRangeInHash("product_" + k + ":SEGD:desc", segmentDetailDescDict);
                //client.SetRangeInHash("product_" + k + ":SEGMEAL:Desc", segmentMealDescDict);
                productIntroDic.Add(k.ToString(), productIntro);
                if (k % 500 == 0)
                {
                    client.SetRangeInHash("product_" + k + ":PrdIntro", productIntroDic);
                    productIntroDic = new Dictionary<string, string>();
                }

                //for (int j = 0; j < segHotelList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":SegHotel_" + j, segHotelList[j]);
                //}
                //for (int j = 0; j <scenicSpotList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":scenicSpot_" + j, scenicSpotList[j]);
                //}
                //for (int j = 0; j < flightsList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":flights_" + j, flightsList[j]);
                //}
                //for (int j = 0; j < xResourceList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":xResource_" + j, xResourceList[j]);
                //}
                //for (int j = 0; j < pictureList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":picture_" + j, pictureList[j]);
                //}
                //for (int j = 0; j < timeEffectList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffect_" + j, timeEffectList[j]);
                //}
                //for (int j = 0; j < timeEffectCityList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffectCity_" + j, timeEffectCityList[j]);
                //}
                //for (int j = 0; j < timeEffectDetailList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffectDetail_" + j, timeEffectDetailList[j]);
                //}
                //for (int j = 0; j < segmentDetailList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":segmentDetail_" + j, segmentDetailList[j]);
                //}
                //for (int j = 0; j < segScenicList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":segScenic_" + j, segScenicList[j]);
                //}
                Console.WriteLine(k);
            }
            client.SetRangeInHash("product_" + k + ":PrdIntro", productIntroDic);

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        static void ProductTest_Flatten()
        {
            Dictionary<string, string> dicProduct = new Dictionary<string, string>();


            IEnumerable<KeyValuePair<string, string>> scenicSpotIterator = new Dictionary<string, string>();
            for (int i = 0; i < 50; i++)
            {
                scenicSpotIterator = scenicSpotIterator.Union(new ScenicSpot().Dummy().ToDictionary());
            }            

            IEnumerable<KeyValuePair<string, string>> flightsIterator = new Dictionary<string, string>();
            for (int i = 0; i < 100; i++)
            {
                flightsIterator = flightsIterator.Union(new Flights().Dummy().ToDictionary());
       
            }

            IEnumerable<KeyValuePair<string, string>> xResourceIterator1 = new Dictionary<string, string>();
            for (int i = 0; i < 100; i++)
            {
                xResourceIterator1 = xResourceIterator1.Union(new XResource().Dummy().ToDictionary());
            }
            IEnumerable<KeyValuePair<string, string>> xResourceIterator2 = new Dictionary<string, string>();
            for (int i = 0; i < 100; i++)
            {
                xResourceIterator2 = xResourceIterator2.Union(new XResource().Dummy().ToDictionary());
            }
          
            //List<string> segmentHotelList = new List<string>();
            List<IEnumerable<KeyValuePair<string, string>>> segmentHotelList = new List<IEnumerable<KeyValuePair<string, string>>>();
            IEnumerable<KeyValuePair<string, string>> segmentHotelIter =new Dictionary<string,string>();
            for (int i = 0; i < 500; i++)
            {
                if (i%50==0)
                {
                    segmentHotelIter = new Dictionary<string, string>();
                    if (i>0)
                    {
                        segmentHotelList.Add(segmentHotelIter); 
                    }
                }
                segmentHotelIter = segmentHotelIter.Union(new SegmentHotel().Dummy().ToDictionary());
            }
            //segmentHotelList.Add(segmentHotelDict);


            IEnumerable<KeyValuePair<string, string>> productIterator = new Dictionary<string, string>();

            for (int i = 0; i < 6; i++)
            {
               productIterator = productIterator.Union(new ControlFlight().Dummy().ToDictionary("CFT:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                productIterator = productIterator.Union(new Hotel().Dummy().ToDictionary("Hotel:" + i));
            }
            for (int i = 0; i < 15; i++)
            {
                productIterator = productIterator.Union(new SegmentDesc().Dummy().ToDictionary());
            }

            IEnumerable<KeyValuePair<string, string>> segmentIter = new Dictionary<string, string>();
            for (int i = 0; i < 10; i++)
            {
                segmentIter = segmentIter.Union(new Segment().Dummy().ToDictionary("Segment:" + i));
            }

            IEnumerable<KeyValuePair<string,string>> rulesIter=new Dictionary<string,string>();
            for (int i = 0; i < 5; i++)
            {
                rulesIter = rulesIter.Union(new FlightRule().Dummy().ToDictionary("FRL:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                rulesIter = rulesIter.Union(new HotelRule().Dummy().ToDictionary("HotelRule:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                rulesIter = rulesIter.Union(new OptionRule().Dummy().ToDictionary("OptionRule:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                rulesIter = rulesIter.Union(new SysFlightRuleDetail().Dummy().ToDictionary("SysFlightRuleDetail:" + i));
            }
            for (int i = 0; i < 5; i++)
            {
                rulesIter = rulesIter.Union(new SysFlightRule().Dummy().ToDictionary("SysFlightRule:" + i));
            }

            IEnumerable<KeyValuePair<string, string>> othersIter = new Dictionary<string, string>();
            
            for (int i = 0; i < 4; i++)
            {
                othersIter = othersIter.Union(new MultiMediaVedio().Dummy().ToDictionary("MultiMediaVedio:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                othersIter = othersIter.Union(new SalesChannel().Dummy().ToDictionary("SalesChannel:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                othersIter = othersIter.Union(new SalesLabel().Dummy().ToDictionary("SalesLabel:" + i));
            }
            for (int i = 0; i < 10; i++)
            {
                othersIter = othersIter.Union(new Calendar().Dummy().ToDictionary("Calendar:" + i));
            }


            //dicProduct.Add("HT:", "Prod:12345:Hotel");
            //dicProduct.Add("SS:", "Prod:12345:ScenicSpot");
            //dicProduct.Add("Flt:", "Prod:12345:Flights");
            //dicProduct.Add("XR:", "Prod:12345:XResource");
            //dicProduct.Add("Sgh:", "Prod:12345:SegmentHotel");
            //dicProduct.Add("Pic:", "Prod:12345:Pictures");
            //dicProduct.Add("TEF:", "Prod:12345:TimeEffectInfo");
            //dicProduct.Add("TEFD:", "Prod:12345:TimeEffectInfoDetail");
            //dicProduct.Add("TEFDC:", "Prod:12345:TimeEffectInfoDetailCity");
            //dicProduct.Add("SegD:", "Prod:12345:SegmentDetail");
            //dicProduct.Add("SegS:", "Prod:12345:SegScenic");

            dicProduct = dicProduct
                .Union(new ProductDesc().Dummy().ToDictionary("ProductDesc:"))
                .Union(new ProductInfo().Dummy().ToDictionary("ProductInfo:"))
                .ToDictionary(kv => kv.Key, kv => kv.Value);

            IEnumerable<KeyValuePair<string, string>> departCityIter = new Dictionary<string, string>();
            for (int i = 0; i < 65; i++)
            {
                departCityIter = departCityIter.Union(new DepartCity().Dummy().ToDictionary("DepartCity:" + i));
            }


            IEnumerable<KeyValuePair<string, string>> segmentMealIter = new Dictionary<string, string>();
            for (int i = 0; i < 50; i++)
            {
                //dictEnumerator = dictEnumerator.Union(new SegmentMeal().Dummy().ToDictionary("SegmentMeal:" + i));
                //SegmentMeal item = new SegmentMeal().Dummy();
                //dicProduct.Add("SegmentMeal:" + i, item.ToJson());
                segmentMealIter = segmentMealIter.Union(new SegmentMeal().Dummy().ToDictionary("SegmentMeal:" + i));
            }

            IEnumerable<KeyValuePair<string, string>> segmentDetailIter = new Dictionary<string, string>();
            for (int i = 0; i < 50; i++)
            {
                segmentDetailIter = segmentDetailIter.Union(new SegmentDetail().Dummy().ToDictionary("SegmentDetail:" + i));
            }

            List<string> segmentDetailDescList = new List<string>();
            for (int i = 0; i < 50; i++)
            {
                string item = new SegmentDetail().Dummy().GetDescription();
                segmentDetailDescList.Add(item);
            }

            //Dictionary<string, string> segmentMealDescDict = new Dictionary<string, string>();
            //for (int i = 0; i < 180; i++)
            //{
            //    string item = new SegmentMeal().Dummy().GetDescription();//.ToJson();
            //    segmentMealDescDict.Add(i.ToString(), item);
            //}
            List<string> segmentMealDescList = new List<string>();

            for (int i = 0; i < 50; i++)
            {
                string item = new SegmentMeal().Dummy().GetDescription();
                segmentMealDescList.Add(item);
            }
            List<TimeEffectInfoDetail> timeEffectInfoDetailList = new List<TimeEffectInfoDetail>();

            IEnumerable<KeyValuePair<string, string>> timeEffectInfoDetailIter = new Dictionary<string, string>();
            for (int i = 0; i < 40; i++)
            {
                timeEffectInfoDetailIter = timeEffectInfoDetailIter.Union(new TimeEffectInfoDetail().Dummy().ToDictionary("TimeEffectInfoDetail:" + i));
            }

            List<string> timeEffectInfoDetailDescList = new List<string>();
            for (int i = 0; i < 40; i++)
            {
                string item = new TimeEffectInfoDetail().Dummy().GetDescDetail();
                timeEffectInfoDetailDescList.Add(item);
            }



            IEnumerable<KeyValuePair<string, string>> sellingCityIter = new Dictionary<string, string>();
            for (int i = 0; i < 65; i++)
            {
                sellingCityIter = sellingCityIter.Union(new SellingCity().Dummy().ToDictionary("SellingCity:" + i));
            }

        
            //List<Dictionary<string, string>> pictureList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> pictureDict = new Dictionary<string, string>();

            IEnumerable<KeyValuePair<string, string>> pictureIter = new Dictionary<string, string>(); 
            for (int i = 0; i < 20; i++)
            {
                pictureIter = pictureIter.Union(new Pictures().Dummy().ToDictionary("Pictures:" + i));
            }


            IEnumerable<KeyValuePair<string, string>> timeEffectIter = new Dictionary<string, string>(); 
            for (int i = 0; i < 60; i++)
            {

                timeEffectIter = timeEffectIter.Union(new TimeEffectInfo().Dummy().ToDictionary("TimeEffectInfo:" + i));       
            }
            //timeEffectList.Add(timeEffectDict);

            //List<Dictionary<string, string>> timeEffectCityList = new List<Dictionary<string, string>>();
            //Dictionary<string, string> timeEffectCityDict = new Dictionary<string, string>();

            IEnumerable<KeyValuePair<string, string>> timeEffectCityIter = new Dictionary<string, string>(); 
            for (int i = 0; i < 50; i++)
            {
                timeEffectCityIter = timeEffectCityIter.Union(new TimeEffectInfoDetailCity().Dummy().ToDictionary("TimeEffectInfoDetailCity:" + i));
            }




            IEnumerable<KeyValuePair<string, string>> segScenicIter = new Dictionary<string, string>(); 
            for (int i = 0; i < 20; i++)
            {
                segScenicIter = segScenicIter.Union(new SegScenic().Dummy().ToDictionary("SegScenic:" + i));
            }


            Stopwatch sw = new Stopwatch();
            sw.Start();
            PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            Dictionary<string, string> productIntroDic = new Dictionary<string, string>();
            string productIntro = new ProductDesc().Dummy().GetIntroduction();
            int k = 0;
            for (k = 0; k < 10000; k++)
            {
                if (k % 4 != 0)
                {
                    dicProduct["ProductDesc:Introduction"] = @"<span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" <span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" <span style=""color:#974806""><p><strong><span style=""color:#ffc000;font-size:16px""></span></strong></p><p><span style=""color:#974806;font-size:14px""></span></p></span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_6"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_7"">?</span><span style=""line-height:0px;display:none"" id=""_baidu_bookmark_start_8"">?</span><span style=""line-height:0px;display:none"" ";
                }
                client.SetRangeInHash("product" + k+ ":rules", rulesIter);
                client.SetRangeInHash("product" + k + ":others", othersIter);
                client.SetRangeInHash("product" + k + ":segment", segmentIter);
                client.SetRangeInHash("product" + k + ":scenic", scenicSpotIterator);
                client.SetRangeInHash("product" + k + ":flights", flightsIterator);
                client.SetRangeInHash("product" + k + ":xres1", xResourceIterator1);
                client.SetRangeInHash("product" + k + ":xres2", xResourceIterator2);
                client.SetRangeInHash("product" + k + ":departCity", departCityIter);
                client.SetRangeInHash("product" + k + ":segmentMeal", segmentMealIter);
                client.SetRangeInHash("product" + k + ":segmentDetail", segmentDetailIter);
                client.SetRangeInHash("product" + k + ":timeEffectInfoDetail", timeEffectInfoDetailIter);
                client.SetRangeInHash("product" + k + ":sellingCity", sellingCityIter);
                client.SetRangeInHash("product" + k + ":picture", pictureIter);
                client.SetRangeInHash("product" + k + ":timeEffectCity", timeEffectCityIter);
                client.SetRangeInHash("product" + k + ":timeEffectInfoDetail", timeEffectInfoDetailIter);
                client.SetRangeInHash("product" + k + ":segScenic", segScenicIter);
                
                
                //RedisClient client = new RedisClient("127.0.0.1", 6379);
                client.SetRangeInHash("product_" + k, dicProduct);
                //client.AddRangeToList("product_" + k + ":SegH", segmentHotelList);
                for (int i = 0; i < segmentHotelList.Count; i++)
                {
                    client.SetRangeInHash("product_" + k + ":SegH"+i, segmentHotelList[i]);
                }
                //client.AddRangeToList("product_" + k + ":Pic", pictureList);
                //client.AddRangeToList("product_" + k + ":TE", timeEffectList);
                //client.AddRangeToList("product_" + k + ":TEC", timeEffectCityList);
                //client.AddRangeToList("product_" + k + ":TED", timeEffectInfoDetailList);
                //client.AddRangeToList("product_" + k + ":SEGD", segmentDetailList);

                client.AddRangeToList("product_" + k + ":SEGDD", segmentDetailDescList);
                client.AddRangeToList("product_" + k + ":SEGMD", segmentMealDescList);
                client.AddRangeToList("product_" + k + ":TEDD", timeEffectInfoDetailDescList);


                //client.AddRangeToList("product_" + k + ":monsters", monsterList);

                //client.SetRangeInHash("product_" + k + ":TED:Desc", timeEffectDetailDescDict);
                //client.SetRangeInHash("product_" + k + ":SEGD:desc", segmentDetailDescDict);
                //client.SetRangeInHash("product_" + k + ":SEGMEAL:Desc", segmentMealDescDict);
                productIntroDic.Add(k.ToString(), productIntro);
                if (k % 500 == 0)
                {
                    client.SetRangeInHash("product_" + k + ":PrdIntro", productIntroDic);
                    productIntroDic = new Dictionary<string, string>();
                }

                //for (int j = 0; j < segHotelList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":SegHotel_" + j, segHotelList[j]);
                //}
                //for (int j = 0; j <scenicSpotList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":scenicSpot_" + j, scenicSpotList[j]);
                //}
                //for (int j = 0; j < flightsList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":flights_" + j, flightsList[j]);
                //}
                //for (int j = 0; j < xResourceList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":xResource_" + j, xResourceList[j]);
                //}
                //for (int j = 0; j < pictureList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":picture_" + j, pictureList[j]);
                //}
                //for (int j = 0; j < timeEffectList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffect_" + j, timeEffectList[j]);
                //}
                //for (int j = 0; j < timeEffectCityList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffectCity_" + j, timeEffectCityList[j]);
                //}
                //for (int j = 0; j < timeEffectDetailList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":timeEffectDetail_" + j, timeEffectDetailList[j]);
                //}
                //for (int j = 0; j < segmentDetailList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":segmentDetail_" + j, segmentDetailList[j]);
                //}
                //for (int j = 0; j < segScenicList.Count; j++)
                //{
                //    client.SetRangeInHash("product_" + i + ":segScenic_" + j, segScenicList[j]);
                //}
                Console.WriteLine(k);
            }
            client.SetRangeInHash("product_" + k + ":PrdIntro", productIntroDic);

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        class DictionaryEqualityComparer : IEqualityComparer<KeyValuePair<string,string>>
        {

            public bool Equals(KeyValuePair<string, string> kv1, KeyValuePair<string, string> kv2)
            {
                if (kv1.Key == kv2.Key)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }


            public int GetHashCode(KeyValuePair<string, string> obj)
            {
                return obj.GetHashCode();
            }
        }

        static void HashGetTest()
        {
            EntityDictionaryMapper.CodeGen_Entity<POCOEntity>();
            EntityDictionaryMapper.CodeGen_Dictionary<POCOEntity>();
            Stopwatch sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < 800000; i++)
            {
                RedisClient client = new RedisClient("127.0.0.1", 6379);
                Dictionary<String, String> dic = client.GetAllEntriesFromHash("poco" + i);

                POCOEntity poco = dic.ToEntity<POCOEntity>();//EntityDictionaryMapper.MapToEntity<POCOEntity>(dic);
                if (i % 10000 == 0)
                {
                    Console.WriteLine(i);
                }
            }

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        static void HashSetGetTest()
        {
            EntityDictionaryMapper.CodeGen_Entity<POCOEntity>();
            EntityDictionaryMapper.CodeGen_Dictionary<POCOEntity>();
            Stopwatch sw = new Stopwatch();
            sw.Start();
            PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            for (int i = 1; i < 20000; i++)
            {
                //RedisClient client = new RedisClient("127.0.0.1", 6379);
                Dictionary<String, String> dic = client.GetAllEntriesFromHash("poco:" + i * 40);
                //dic = dic.OrderBy(d=>d.Key).ToDictionary(kv=>kv.Key,kv=>kv.Value);
                //List<string> prefixList = new List<string>();
                //for (int j = 0; j < 40; j++)
                //{
                //    int index = (i - 1) * 40 + j;
                //    prefixList.Add(index + ":");
                //}
                //dic.Remove("head");
                List<POCOEntity> pocoList = dic.ToEntityList<POCOEntity>();////EntityDictionaryMapper.MapToEntityList<POCOEntity>(dic);//, prefixList.ToArray());

                Console.WriteLine(i);
            }

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        static void HashSetTest()
        {

            EntityDictionaryMapper.CodeGen_Entity<POCOEntity>();
            EntityDictionaryMapper.CodeGen_Dictionary<POCOEntity>();
            int counter = 0;
            POCOEntity poco = new POCOEntity { Id = 1, Name = "poco" };// = new POCOEntity();
            //Dictionary<String, String> dic = new Dictionary<string, string>();
            string[] propNames = BuildDummyData(poco);

            Stopwatch sw = new Stopwatch();
            sw.Start();
            Console.WriteLine("start");
            Dictionary<String, String> dicSets = new Dictionary<string, string>();
            PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            for (int i = 1; i <= 800000; i++)
            {
                poco.Id = i;
                Dictionary<String, String> dic = new Dictionary<string, string>();
                dic = poco.ToDictionary(i + ":", propNames);// EntityDictionaryMapper.MapToDictionary<POCOEntity>(poco, i + ":", propNames);

                dicSets = dicSets.Union(dic).ToDictionary(kv => kv.Key, kv => kv.Value);
                if (i % 40 == 0)
                {
                    //IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
                    string key = "poco:" + i;
                    //client.SetEntryInHashIfNotExists(key, "head", "head");
                    client.SetRangeInHash(key, dicSets);
                    dicSets.Clear();
                    Console.WriteLine(key);
                }

                counter++;
            };
            sw.Stop();
            Console.WriteLine(counter);
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        static void HashTest()
        {
            EntityDictionaryMapper.CodeGen_Entity<POCOEntity>();
            EntityDictionaryMapper.CodeGen_Dictionary<POCOEntity>();
            int counter = 0;
            POCOEntity poco = new POCOEntity { Id = 1, Name = "poco" };// = new POCOEntity();
            //Dictionary<String, String> dic = new Dictionary<string, string>();
            string[] propNames = BuildDummyDataMini(poco);
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Console.WriteLine("start");
            //Parallel.For(0, 800000, i =>
            for (int i = 0; i < 800000; i++)
            {
                RedisClient client = new RedisClient("127.0.0.1", 6379);
                string index = i.ToString();
                Dictionary<String, String> dic = new Dictionary<string, string>();
                //dic = new Dictionary<string, string>();
                //{
                //{ "Id", "1" }, 
                //{ "Name", "poco" } 
                //};
                //poco = EntityDictMapper.MapToEntities<POCOEntity>(dic);
                dic = poco.ToDictionary(propNames);// EntityDictionaryMapper.MapToDictionary<POCOEntity>(poco, propNames);
                //Dictionary<string, string> dic_mapped = EntityDictMapper.MapToDictionary(poco,"Id","Name");
                //dic.InjectFrom<EntityToDictionaryInjection>(poco);
                //poco.InjectFrom<DictionaryToEntityInjection>(dic);
                //Interlocked.Add(ref counter, 1);
                counter++;
                client.SetEntryInHashIfNotExists("poco" + index, "head", "head");
                client.SetRangeInHash("poco" + index, dic);
            }
            sw.Stop();
            Console.WriteLine(counter);
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }
        static void EntryTest()
        {
            int counter = 0;
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Console.WriteLine("start");
            POCOEntity poco = new POCOEntity { Id = 1, Name = "poco" };// = new POCOEntity();
            //Dictionary<String, String> dic = new Dictionary<string, string>();
            BuildDummyDataMini(poco);
            PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            for (int i = 0; i < 800000; i++)
            {
                string index = i.ToString();
                //RedisClient client = new RedisClient("127.0.0.1", 6379);
                client.Add<POCOEntity>("poco_entry" + index, poco);
                counter++;
            }
            sw.Stop();
            Console.WriteLine(counter);
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }
        static void EntryListTest()
        {

            int counter = 0;
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Console.WriteLine("start");
            POCOEntity poco = new POCOEntity { Id = 1, Name = "poco" };// = new POCOEntity();
            //Dictionary<String, String> dic = new Dictionary<string, string>();
            BuildDummyData(poco);
            Dictionary<string, string> entityDic = new Dictionary<string, string>();
            
            Dictionary<string, byte[]> entityBytesDic = new Dictionary<string, byte[]>();
            //PooledRedisClientManager mgr = new PooledRedisClientManager("127.0.0.1:6379");
            
            //IRedisClient client = mgr.GetClient();//new RedisClient("127.0.0.1", 6379);
            RedisNativeClient client = new RedisNativeClient("127.0.0.1", 6379);
            for (int i = 0; i < 800000; i++)
            {
                //RedisClient client = new RedisClient("127.0.0.1", 6379);
                string index = i.ToString();

                if (i > 0 && i % 40 == 0)
                {
                    string key = "poco:" + i;
                    client.HMSet(key, entityBytesDic.Keys.Select(k => k.ToUtf8Bytes()).ToArray(), entityBytesDic.Values.ToArray());
                    //client.SetRangeInHash(key, entityDic);
                    entityDic = new Dictionary<string, string>();
                    entityBytesDic = new Dictionary<string, byte[]>();
                    Console.WriteLine(i);
                }
                using (MemoryStream ms = new MemoryStream())
                {
                    ProtoBuf.Serializer.Serialize<POCOEntity>(ms, poco);
                    
                    byte[] value = ms.ToArray();
                    entityBytesDic.Add(i + ":", value);
                }
                //entityDic.Add(i + ":", JsonSerializer.SerializeToString<POCOEntity>(poco));    
                counter++;
            }
            sw.Stop();
            Console.WriteLine(counter);
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }
        static void EntryGetTest()
        {
            int counter = 0;
            Stopwatch sw = new Stopwatch();
            sw.Start();
            Console.WriteLine("start");
            for (int i = 0; i < 800000; i++)
            {
                string index = i.ToString();
                RedisClient client = new RedisClient("127.0.0.1", 6379);

                POCOEntity poco = client.Get<POCOEntity>("poco_entry" + index);
                counter++;
                if (i % 10000 == 0)
                {
                    Console.WriteLine(i);
                }
            }
            sw.Stop();
            Console.WriteLine(counter);
            Console.WriteLine(sw.ElapsedMilliseconds);
            Console.WriteLine("done");
        }

        private static string[] BuildDummyData(POCOEntity poco)
        {
            #region dummy data
            PropertyInfo[] props = typeof(POCOEntity).GetProperties();
            string[] propNames = props.Select(p => p.Name).ToArray();
            foreach (var pi in props)
            {
                if (pi.PropertyType == typeof(string))
                {
                    #region fill poco
                    pi.SetValue(poco, @"上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12
上海--三亚--上海 2014-12-12 10:09:12", null);
                    #endregion
                }
            }
            poco.Name = "<span style=\"color:#974806\"><p><strong><span style=\"color:#ffc000;font-size:16px\"></span></strong></p><p><span style=\"color:#974806;font-size:14px\"></span></p></span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_6\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_7\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_8\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_9\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_10\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_11\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_12\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_13\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_14\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_15\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_16\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_17\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_18\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_19\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_20\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_21\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_22\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_23\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_24\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_25\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_26\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_27\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_28\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_29\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_30\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_31\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_32\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_33\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_34\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_35\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_36\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_37\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_38\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_39\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_40\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_41\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_42\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_43\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_44\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_45\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_46\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_47\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_48\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_49\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_50\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_51\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_52\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_53\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_54\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_55\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_56\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_57\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_58\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_59\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_60\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_61\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_62\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_63\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_64\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_65\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_66\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_67\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_68\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_69\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_70\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_71\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_72\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_73\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_74\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_75\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_76\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_77\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_78\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_79\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_80\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_81\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_82\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_83\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_84\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_85\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_86\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_87\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_88\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_89\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_90\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_91\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_92\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_93\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_94\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_95\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_96\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_97\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_98\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_99\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_100\">?</span><span style=\"line-height:0px;display:none\" id=\"_baidu_bookmark_start_101\">?</span>&lt;span style=&quot;line-height:0px;display:none&quot; id=&";
            #region fill dictionary
            //            dic["Id"] = "1";
            //            dic["Name"] = @"上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12";
            //            for (int i = 1; i <= 100; i++)
            //            {
            //                dic["Name" + i] = @"上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12";
            //            }
            #endregion
            #endregion

            return propNames;
        }


        private static string[] BuildDummyDataMini(POCOEntity poco)
        {
            #region dummy data
            PropertyInfo[] props = typeof(POCOEntity).GetProperties();
            string[] propNames = props.Select(p => p.Name).ToArray();
            foreach (var pi in props)
            {
                if (pi.PropertyType == typeof(string))
                {
                    #region fill poco
                    pi.SetValue(poco, @"上海--三亚--上海 2014-12-12", null);
                    #endregion
                }
            }
            #region fill dictionary
            //            dic["Id"] = "1";
            //            dic["Name"] = @"上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12";
            //            for (int i = 1; i <= 100; i++)
            //            {
            //                dic["Name" + i] = @"上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12
            //上海--三亚--上海 2014-12-12 10:09:12";
            //            }
            #endregion
            #endregion

            return propNames;
        }

        public class CacheRecord
        {
            public CacheRecord()
            {
                this.Children = new List<CacheRecordChild>();
            }

            public string Id { get; set; }
            public List<CacheRecordChild> Children { get; set; }
        }

        public class CacheRecordChild
        {
            public string Id { get; set; }
            public string Data { get; set; }
        }

        static void Test()
        {
            Thread.Sleep(1000);
        }

        private static void ExpireTest()
        {
            String key = "expired:counter";
            RedisClient client = new RedisClient("127.0.0.1", 6379);
            client.Incr(key);
            client.ExpireEntryIn(key, new TimeSpan(0, 0, 60));
            double timeToLive = client.GetTimeToLive(key).TotalSeconds;
            Console.WriteLine(timeToLive);

            var cachedRecord = new CacheRecord
            {
                Id = "expired:entity",
                Children = {
					new CacheRecordChild { Id = "childKey", Data = "data" }
				}
            };

            var redis = client.As<CacheRecord>();
            key = IdUtils.CreateUrn<CacheRecord>(cachedRecord.Id);
            Console.WriteLine(key);
            client.Store(cachedRecord);
            Console.WriteLine(client.Get<CacheRecord>(key).Id);
            client.ExpireEntryIn(key, TimeSpan.FromSeconds(60));

            timeToLive = client.GetTimeToLive(key).TotalSeconds;
            Console.WriteLine(timeToLive);

        }

        private static void SleepTest()
        {
            Parallel.For(0, 10000, (i) =>
                {
                    Thread t = Thread.CurrentThread;
                    int tid = t.ManagedThreadId;
                    int hashCode = t.GetHashCode();
                    Thread.Sleep(1000);
                    //if (tid != Thread.CurrentThread.ManagedThreadId)
                    //{
                    Console.WriteLine(string.Format("wake up in thread {0}:{1} from thread {2}:{3}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.GetHashCode(), tid, hashCode));
                    //}
                }
                );
        }

        private static void ListTest()
        {
            RedisClient client = new RedisClient("127.0.0.1", 6379);

            client.GetAllItemsFromList("products").ForEach(i => Console.WriteLine(i));
            client.RemoveAllFromList("products");
            //for (int j = 0; j < 2; j++)
            //{

            RedisClient client1 = new RedisClient("127.0.0.1", 6379);


            for (int i = 0; i < 100000; i++)
            {
                client1.AddItemToList("products", string.Format("product{0}", i));
            }
            //}
            Console.WriteLine("done! press any key to close");
            Console.ReadKey();
        }

        private static void SortedSetTest()
        {

            RedisClient client = new RedisClient("127.0.0.1", 6379);
            client.GetAllItemsFromSortedSet("productset").ForEach(i => Console.WriteLine(i));

            int count = client.SortedSets["productset"].Count;
            Console.WriteLine(string.Format("clear {0}done!", client.RemoveRangeFromSortedSetByScore("productset", 0, count - 1)));
            for (int i = 0; i < 1000000; i++)
            {
                client.AddItemToSortedSet("productset", string.Format("product{0}", i), i);
            }
            Console.WriteLine("add items done!");
            Console.WriteLine("remove 12345:" + client.RemoveRangeFromSortedSetByScore("productset", 12345, 12345));
            Console.WriteLine("remove product54321:" + client.RemoveItemFromSortedSet("productset", "product54321"));
            Console.WriteLine("find product12345:" + client.GetItemIndexInSortedSet("productset", "product12345"));
            Console.WriteLine("add product12345:" + client.AddItemToSortedSet("productset", "product12345", 12345));
            Console.WriteLine("find product12345:" + client.GetItemIndexInSortedSet("productset", "product12345"));
            Console.WriteLine("remove done! press any key to close");
            Console.ReadKey();
        }

        private static void INCRTest()
        {
            var result = Parallel.For(0, 5000000, (i) =>
            {
                RedisClient client = new RedisClient("127.0.0.1", 6379);
                long counter = client.Incr("counter");
                if (counter <= 100)
                {
                    Console.WriteLine(string.Format("congratulations! you got :{0}", counter));
                }
            });
            while (!result.IsCompleted)
            {
                Thread.Sleep(200);
            }
            //for (int i = 0; i < 10000; i++)
            //{

            //}
        }

        //private static void INCRFromNode()
        //{
        //    for (int i = 0; i < 10000; i++)
        //    {
        //        Promotion();
        //    }
        //}

        //private static async void Promotion()
        //{
        //    HttpWebRequest request = HttpWebRequest.Create("http://localhost:3001/promotion") as HttpWebRequest;
        //    request.Method = "POST";
        //    using (WebResponse response = await request.GetResponseAsync())
        //    {
        //        using (Stream stream = response.GetResponseStream())
        //        {
        //            using (StreamReader sr = new StreamReader(stream))
        //            {
        //                string result = sr.ReadToEnd();
        //                if (result.IndexOf("end") < 0)
        //                {
        //                    if (Interlocked.Add(ref counter, 1) >= 100)
        //                    {
        //                        Console.WriteLine(counter);
        //                    }
        //                    Console.WriteLine(result);
        //                }
        //            }
        //        }
        //    }
        //}
    }
}
